package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.SingIn;
import cn.wolfcode.trip.base.service.ISiginService;
import cn.wolfcode.trip.base.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("signInDate")
public class SinginController {
    /**
     * 查询所有的签到次数
     */
    @Autowired
    ISiginService siginService;
    @Autowired
    IUserService userService;


    @RequestMapping(value="/{id}/listAllSignInDate",method = RequestMethod.GET)
    public List<SingIn> listAllSignInDate(@PathVariable Long id){

        return siginService.listAllSignInDate(id);
    }

    /**
     * 保存签到次数
     *
     */
    @RequestMapping(value="/{user.id}",method = RequestMethod.POST)
    public void  insert( Long id, SingIn singIn ){
        singIn.setUser(userService.selectByPrimaryKey(id));
        Date date = new Date();
        singIn.setSinginday(date);
         siginService.insert(singIn);
    }

}
